public class LoadBalancer
{
    static LoadBalancer? instance;

    List<string> servers = new List<string>();
    Random random = new Random();
    ///锁对象
    private static object locker = new object();
    protected LoadBalancer()
    {
        servers.Add("serverI");
        servers.Add("serverII");
    }
    //获取实例
    public static LoadBalancer GetLoadBalancer()
    {
        //双重检测
        if (instance == null)
        {
            lock (locker)
            {
                if (instance == null)
                {
                    instance = new LoadBalancer();
                }
            }
        }
        return instance;
    }

    public string Server
    {
        get
        {
            int r = random.Next(servers.Count);
            return servers[r].ToString();
        }
    }
}